package com.mryin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mryin.mapper.EmployeesMapper;
import com.mryin.pojo.Employees;
import com.mryin.util.DataGridView;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Mr.Yin
 * @create: 2021-02-27 21:57
 **/
@RestController
@Api(tags = "登录的一些接口")
@RequestMapping("/api/employees")
public class EmployeesController {
    @Autowired
    private EmployeesMapper employeesMapper ;

    @RequestMapping("employee")
    public DataGridView employeesList(@RequestParam("page")Integer pageNum,
                                      @RequestParam("limit")Integer pageSize){
        System.out.println(pageNum);
        System.out.println(pageSize);
        Page<Employees> page = new Page<>(pageNum,pageSize);
        long total = page.getTotal();
        return new DataGridView(0,"查询成功",
                total,employeesMapper.selectPage(page,null).getRecords());
    }
}